import context.Order;
import factory.PaymentStrategyFactory;
import service.IPaymentStrategy;

/**
 * 结合工厂模式的使用示例
 */
public class StrategyWithFactoryDemo {
    public static void main(String[] args) {
        Order order = new Order(500.00);
        
        // 使用工厂创建策略
        IPaymentStrategy strategy = PaymentStrategyFactory.createStrategy(
            PaymentStrategyFactory.PaymentType.ALIPAY, 
            "wangwu@alipay.com"
        );
        
        order.setPaymentStrategy(strategy);
        order.executePayment();

        strategy = PaymentStrategyFactory.createStrategy(
                PaymentStrategyFactory.PaymentType.WECHAT,
                "wx_openid_123456"
        );

        order.setPaymentStrategy(strategy);
        order.executePayment();

        strategy = PaymentStrategyFactory.createStrategy(
                PaymentStrategyFactory.PaymentType.CREDIT_CARD,
                "1234567812345678", "1234"
        );

        order.setPaymentStrategy(strategy);
        order.executePayment();
    }
}